package main

import (
	"github.com/gin-gonic/gin"
	"github.com/sirupsen/logrus"
	"hcy-api/lib/middleware"
	"idp/global"
	"idp/job"
	"idp/listener"
)

func main() {
	defer logrus.Panic("系统崩溃")
	//初始化配置
	global.InitIdpConfig("config_idp.yaml")
	// 加载缓存
	listener.LoadIdpCatch()
	// 启动tcp服务
	listener.InitTcpServer()
	// 启动定时任务
	job.Start()
	// 初始化http服务
	app := gin.New()
	static := app.Group("/api/idp/static")
	static.Static("/pic", global.IdpConf.PicPath)
	static.Static("/map", global.IdpConf.JsonMapPath)
	r := app.Group("/api/idp")
	r.Use(middleware.HttpLog())
	RegisterRouter(r)
	err := app.Run(global.IdpConf.Http.Addr)
	if err != nil {
		logrus.Errorf("http服务启动失败：%s", err)
	}
}
